%script to generate negatives samples

close all, clear all;

inriaSrcFolder = 'C:/Users/RFSC/Desktop/DataSet/INRIAPerson';
targetFolder = 'neg';
filesNamesPath = 'neg.lst';
height = 128;
width = 64;
windowPerImage = 10;

[files] = textread(filesNamesPath, '%s', -1);

for fileIdx = 1:length(files)
    path = strcat(inriaSrcFolder,'/',files(fileIdx));
    [pathstr,name,ext] =  fileparts(path{1});
    
    image = imread(path{1});
    [imHeight, imWidth, ~] = size(image);
    
    for r = 1:windowPerImage
       cropPosx = randi(imWidth - width);
       cropPosy = randi(imHeight - height);
       targetPath = strcat(targetFolder,'/',name,'_',num2str(r),ext);

             
      
       window = imcrop(image, [cropPosx, cropPosy, width - 1, height - 1 ]);
       
       
       imwrite(window,targetPath)
    end;
end;